﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms.DataVisualization.Charting;
using AutoMachine;

namespace Tool
{
    public   class ChartShow
    {

        /// <summary>
        /// 绘制图表方法
        /// </summary>
        /// <param name="chart">哪个图表</param>
        /// <param name="chartType">类型</param>
        public static void ShowChart(Chart chart, SeriesChartType chartType, string[] Time)
        {

            //1.清除所有的图表序列
            chart.Series.Clear();

            //2.
            // this.chart.Legends.Clear();
            //3D
            chart.ChartAreas[0].Area3DStyle.Enable3D = true;
            chart.ChartAreas[0].Area3DStyle.Inclination = 50;
            chart.ChartAreas[0].Area3DStyle.PointDepth = 50;
            chart.ChartAreas[0].Area3DStyle.IsClustered = true;
            chart.ChartAreas[0].AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount;

            //创建图表序列
            Series series1 = new Series();//总数
            series1.LegendText = "OK数量";
            series1.ChartType = chartType;
            chart.Series.Add(series1);

            Series series2 = new Series();//OK数量
            series2.LegendText = "NG数量";
            series2.ChartType = chartType;
            chart.Series.Add(series2);

            Series series3 = new Series();//NG数量                    
            series3.LegendText = "总数量";
            series3.ChartType = chartType;
            chart.Series.Add(series3);

            //X轴间隔
            chart.ChartAreas[0].AxisX.Interval = 1; //一般都设置为1
            //Y轴间隔
            chart.ChartAreas[0].AxisY.Interval = 50;//也可以设置成20    

            for (int i = 0; i < Time.Length; i++)
            {
                int data = Convert.ToInt16(Time[i]);
                series1.Points.AddXY(data + "时", Count.OKArray[data]);
                series2.Points.AddXY(data + "时", Count.NGArray[data]);
                series3.Points.AddXY(data + "时", Count.TotalArray[data]);

                series1.Points[i].Label = Convert.ToString(Count.OKArray[data]);
                series2.Points[i].Label = Convert.ToString(Count.NGArray[data]);
                series3.Points[i].Label = Convert.ToString(Count.TotalArray[data]);

            }
        }

        /// <summary>
        /// 绘制图表方法
        /// </summary>
        /// <param name="chart">哪个图表</param>
        /// <param name="chartType">类型</param>
        public static void ShowChart1(Chart chart, SeriesChartType chartType, string[] Time)
        {

            //1.清除所有的图表序列
            chart.Series.Clear();

            //2.
            // this.chart.Legends.Clear();
            //3D
            chart.ChartAreas[0].Area3DStyle.Enable3D = true;
            chart.ChartAreas[0].Area3DStyle.Inclination = 50;
            chart.ChartAreas[0].Area3DStyle.PointDepth = 50;
            chart.ChartAreas[0].Area3DStyle.IsClustered = true;
            chart.ChartAreas[0].AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount;

            //创建图表序列
            Series series1 = new Series();//总数
            series1.LegendText = "OK数量";
            series1.ChartType = chartType;
            chart.Series.Add(series1);

            Series series2 = new Series();//OK数量
            series2.LegendText = "NG数量";
            series2.ChartType = chartType;
            chart.Series.Add(series2);

            Series series3 = new Series();//NG数量                    
            series3.LegendText = "总数量";
            series3.ChartType = chartType;
            chart.Series.Add(series3);

            //X轴间隔
            chart.ChartAreas[0].AxisX.Interval = 1; //一般都设置为1
            //Y轴间隔
            chart.ChartAreas[0].AxisY.Interval = 50;//也可以设置成20    

            for (int i = 0; i < Time.Length; i++)
            {
                int data = Convert.ToInt16(Time[i]);
                series1.Points.AddXY(data + "时", Count.TotalArray[data]);
                series2.Points.AddXY(data + "时", Count.OKArray[data]);
                series3.Points.AddXY(data + "时", Count.NGArray[data]);

                series1.Points[i].Label = Convert.ToString(Count.TotalArray[data]);
                series2.Points[i].Label = Convert.ToString(Count.OKArray[data]);
                series3.Points[i].Label = Convert.ToString(Count.NGArray[data]);
            }
        }


    }
}
